package com.cdn.allmobilestore.loader;

import android.widget.AbsListView;

public class Pager implements AbsListView.OnScrollListener
{
  private Runnable mCallback;
  private boolean mNeedLoad;

  public Pager(Runnable runable)
  {
    this.mCallback = runable;
    this.mNeedLoad = false;
  }

  public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
  {
    if ((totalItemCount > visibleItemCount) && (totalItemCount - visibleItemCount / 2 <= firstVisibleItem + visibleItemCount))
    {
      this.mNeedLoad = true;
      if ((this.mNeedLoad) && (this.mCallback != null))
        this.mCallback.run();     
    }
  }

  public void onScrollStateChanged(AbsListView view, int scrollState)
  {
  }
}